<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
                "http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
  <title>Description of getCoefficientFromString</title>
  <meta name="keywords" content="getCoefficientFromString">
  <meta name="description" content="Take the coefficients of variables that don't have, for construction, any divisor.">
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  <meta name="generator" content="m2html v1.5 &copy; 2003-2005 Guillaume Flandin">
  <meta name="robots" content="index, follow">
  <link type="text/css" rel="stylesheet" href="../m2html.css">
</head>
<body>
<a name="_top"></a>
<div><a href="../index.html">Home</a> &gt;  <a href="index.html">source</a> &gt; getCoefficientFromString.m</div>

<!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png">&nbsp;Master index</a></td>
<td align="right"><a href="index.html">Index for source&nbsp;<img alt=">" border="0" src="../right.png"></a></td></tr></table>-->

<h1>getCoefficientFromString
</h1>

<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="box"><strong>Take the coefficients of variables that don't have, for construction, any divisor.</strong></div>

<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="box"><strong>function [ coefficient ] = getCoefficientFromString( chr ) </strong></div>

<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="fragment"><pre class="comment">Take the coefficients of variables that don't have, for construction, any divisor.

Take the coefficients of variables that don't have, for construction, any
divisor.

Prototype: [coefficient] = getCoefficientFromString(chr)

Input:     chr - String vector of an equation

Output:    coefficient - Wanted coefficient</pre></div>

<!-- crossreference -->
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
This function calls:
<ul style="list-style-image:url(../matlabicon.gif)">
<li><a href="strsplit.html" class="code" title="function parts = strsplit( splitstr, str, option )">strsplit</a>	Split string into pieces.</li></ul>
This function is called by:
<ul style="list-style-image:url(../matlabicon.gif)">
<li><a href="extendedMatrix.html" class="code" title="function [ Ae ] = extendedMatrix( A, n, m, hState, d )">extendedMatrix</a>	Calculate the Extended Matrix of matrix A as single matrix.</li></ul>
<!-- crossreference -->



<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="fragment"><pre>0001 <span class="comment">%Take the coefficients of variables that don't have, for construction, any divisor.</span>
0002 <span class="comment">%</span>
0003 <span class="comment">%Take the coefficients of variables that don't have, for construction, any</span>
0004 <span class="comment">%divisor.</span>
0005 <span class="comment">%</span>
0006 <span class="comment">%Prototype: [coefficient] = getCoefficientFromString(chr)</span>
0007 <span class="comment">%</span>
0008 <span class="comment">%Input:     chr - String vector of an equation</span>
0009 <span class="comment">%</span>
0010 <span class="comment">%Output:    coefficient - Wanted coefficient</span>
0011 
0012 <a name="_sub0" href="#_subfunctions" class="code">function [ coefficient ] = getCoefficientFromString( chr )</a>
0013 
0014 chr = strrep(chr, <span class="string">' '</span>, <span class="string">''</span>);
0015 chr = strrep(chr, <span class="string">'+'</span>, <span class="string">' +'</span>);
0016 chr = strrep(chr, <span class="string">'-'</span>, <span class="string">' -'</span>);
0017 pieces = <a href="strsplit.html" class="code" title="function parts = strsplit( splitstr, str, option )">strsplit</a>(<span class="string">' '</span>, chr);
0018 <span class="keyword">if</span> cellfun(@isempty, pieces(1))
0019     pieces(1) = [];
0020 <span class="keyword">end</span>
0021 
0022 i = 1;
0023 coefficient = 0;
0024 warning off
0025 <span class="keyword">while</span> i &lt;= length(pieces)
0026     <span class="keyword">if</span> cellfun(@isempty,strfind(pieces(i),<span class="string">'/'</span>))==true
0027         coefficient = strcat(coefficient,char(pieces(i)));
0028     <span class="keyword">end</span>
0029     i = i + 1;
0030 <span class="keyword">end</span>
0031 
0032 warning on
0033 
0034 <span class="keyword">return</span>;
0035 
0036 <span class="keyword">end</span></pre></div>
<hr><address>Generated on Mon 12-Oct-2009 21:15:56 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/" title="Matlab Documentation in HTML">m2html</a></strong> &copy; 2005</address>
</body>
</html>